package study.springcloud.gateway.support.route;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
//@Configuration
public class RouteConfig {

//    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        RouteLocator locator = builder.routes()
                .route(p -> p.path("/study-springcloud-consumer-rest/**")
                        .filters(f -> f.stripPrefix(1))
                        .uri("lb://study-springcloud-consumer-rest")
//                        .order(0)
                        .id("study-springcloud-consumer-rest")).build();
        return locator;
    }
}
